package nl.infodation.emr.pricingservice.entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import nl.infodation.emr.pricingservice.data.AdvantageItem;
import nl.infodation.emr.pricingservice.data.ConditionItem;
import nl.infodation.emr.utility.Constants;

import org.apache.commons.lang.StringUtils;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

@Entity
@Table(name = "promotion")
public class DomainRule {
	
	public enum CustomerVip {
		VIP("VIP"), NONE("");
		
		private String val;
		
		CustomerVip(String val) {
			this.val = val;
		}
		
		public String value() {
			return val;
		}
	}
	
	private static final String FIX_PRICE = "FIX_PRICE"; 

	public static enum PriceType {
		SELLING_PRICE("SELLING_PRICE"),REAL_PRICE("REAL_PRICE");
		
		private String val;
		
		PriceType(String val) {
			this.val = val;
		}
		
		public String value() {
			return val;
		}
		
		public static PriceType parse(String id) {
			PriceType priceType = null; // Default
            for (PriceType item : PriceType.values()) {
                if (item.value().equals(id)) {
                	priceType = item;
                    break;
                }
            }
            return priceType;
        }
	}
	@Id
	@Column(name = "promotion_id")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long domainRuleId;

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
	@LazyCollection(LazyCollectionOption.EXTRA)
	@JoinColumn(name = "environment_id")
	private Environment environment;

	@Column(name = "shipping_discount_percent_value")
	private String shippingDiscountPercentValue;

	@Column(name = "shipping_discount_percent_enable")
	private Boolean shippingDiscountPercentEnable;

	@Column(name = "order_discount_percent_value")
	private String orderDiscountPercentValue;

	@Column(name = "order_discount_percent_enable")
	private Boolean orderDiscountPercentEnable;

	@Column(name = "rule_id")
	private String ruleId;

	@Column(name = "rule_name")
	private String ruleName;

	@Column(name = "description")
	private String description;

	@Column(name = "descriptionID")
	private String descriptionId;

	@Column(name = "salience")
	private int salience;

	@Column(name = "bus_line")
	private String busLine;

	@Column(name = "country")
	private String country;

	@Column(name = "begin_date")
	private Date beginDate;

	@Column(name = "end_date")
	private Date endDate;

	@Column(name = "promotion_code_enable")
	private Boolean promotionCodeEnable;

	@Column(name = "promotion_value")
	private String promotionValue;

	@Column(name = "currency_enable")
	private Boolean currencyEnable;

	@Column(name = "currency_value")
	private String currencyValue;

	@Column(name = "channel_enable")
	private Boolean channelEnable;

	@Column(name = "channel_value")
	private String channelValue;

	@Column(name = "language_enable")
	private Boolean languageEnable;

	@Column(name = "language_value")
	private String languageValue;

	@Column(name = "payment_mode_enable")
	private Boolean paymentModeEnable;

	@Column(name = "payment_mode_value")
	private String paymentModeValue;

	@Column(name = "shipping_mode_enable")
	private Boolean shippingModeEnable;

	@Column(name = "shipping_mode_value")
	private String shippingModeValue;

	@Column(name = "sales_id_enable")
	private Boolean salesIdEnable;

	@Column(name = "sales_id_value")
	private String salesIdValue;

	@Column(name = "city_type_enable")
	private Boolean cityTypeEnable;

	@Column(name = "city_type_value")
	private String cityTypeValue;

	@Column(name = "order_amount")
	private String orderAmount;

	@Column(name = "line_amount")
	private String lineAmount;

	@Column(name = "nb_of_items_per_order")
	private String nbOfItemsPerOrder;

	@Column(name = "marketing_action_code")
	private String marketingActionCode;

	@Column(name = "family_enable")
	private Boolean familyEnable;

	@Column(name = "family_value")
	private String familyValue;

	@Column(name = "sub_family_enable")
	private Boolean subFamilyEnable;

	@Column(name = "sub_family_value")
	private String subFamilyValue;

	@Column(name = "product_code_enable")
	private Boolean productCodeEnable;

	@Column(name = "product_code_value")
	private String productCodeValue;

	@Column(name = "one_product_for_each_sub_family_enable")
	private Boolean oneProductForEachSubFamilyEnable;

	@Column(name = "one_product_for_each_sub_family_value")
	private String oneProductForEachSubFamilyValue;

	@Column(name = "lots_enable")
	private Boolean lotsEnable;

	@Column(name = "lots_value")
	private String lotsValue;

	@Column(name = "brand_enable")
	private Boolean brandEnable;

	@Column(name = "brand_value")
	private String brandValue;

	@Column(name = "offer_id_enable")
	private Boolean offerIdEnable;

	@Column(name = "offer_id_value")
	private String offerIdValue;

	@Column(name = "bundle_definition_enable")
	private Boolean bundleDefinitionEnable;

	@Column(name = "bundle_definition_value")
	private String bundleDefinitionValue;

	@Column(name = "gift_enable")
	private Boolean giftEnable;

	@Column(name = "product_code")
	private String productCode;

	@Column(name = "product_id")
	private String productId;

	@Column(name = "commercial_ref")
	private String commercialRef;

	@Column(name = "item_id")
	private String itemId;

	@Column(name = "order_shipping_fee_enable")
	private Boolean orderShippingFeeEnable;

	@Column(name = "order_shipping_fee_value")
	private String orderShippingFeeValue;

	@Column(name = "orderline_shipping_fee_enable")
	private Boolean orderlineShippingFeeEnable;

	@Column(name = "orderline_shipping_fee_value")
	private String orderlineShippingFeeValue;

	@Column(name = "orderline_discount_percentage_enable")
	private Boolean orderlineDiscountPercentageEnable;

	@Column(name = "orderline_discount_percentage_value")
	private String orderlineDiscountPercentageValue;

	@Column(name = "orderline_discount_enable")
	private Boolean orderlineDiscountEnable;

	@Column(name = "orderline_discount_value")
	private String orderlineDiscountValue;

	@Column(name = "orderline_shipping_fee_discount_percentage_enable")
	private Boolean orderlineShippingFeeDiscountPercentageEnable;

	@Column(name = "orderline_shipping_fee_discount_percentage_value")
	private String orderlineShippingFeeDiscountPercentageValue;

	@Column(name = "order_propose_discount_enable")
	private Boolean orderProposeDiscountEnable;

	@Column(name = "order_propose_discount_value")
	private String orderProposeDiscountValue;

	@Column(name = "orderline_selling_price_enable")
	private Boolean orderlineSellingPriceEnable;

	@Column(name = "orderline_selling_price_value")
	private String orderlineSellingPriceValue;

	@Column(name = "discount_for_cheapest_refco_enable")
	private Boolean discountForCheapestRefcoEnable;

	@Column(name = "family")
	private String family;

	@Column(name = "add_refco_from_salesupport_enable")
	private Boolean addRefcoFromSalesupportEnable;

	@Column(name = "from_salesupport_offer")
	private String fromSalesupportOffer;

	@Column(name = "category")
	private String category;

	@Column(name = "add_refco_of_order_enable")
	private Boolean addRefcoOfOrderEnable;

	@Column(name = "of_order_offer")
	private String ofOrderOffer;

	@Column(name = "add_refco_enable")
	private Boolean addRefcoEnable;

	@Column(name = "refco")
	private String refco;

	@Column(name = "category_enable")
	private Boolean categoryEnable;

	@Column(name = "category_value")
	private String categoryValue;

	@Column(name = "more_than_x_of_family_enable")
	private Boolean moreThanXOfFamilyEnable;

	@Column(name = "more_than_x_of_family_value")
	private String moreThanXOfFamilyValue;

	@Column(name = "product_id_value")
	private String productIdValue;

	@Column(name = "product_id_enable")
	private Boolean productIdEnable;

	@Column(name = "promotion_active")
	private Boolean promotionActive;

	@Column(name = "net_amount")
	private String netAmount;

	@Column(name = "delivery_mode_price_range_value")
	private String deliveryModePriceRangeValue;

	@Column(name = "delivery_mode_price_range_enable")
	private Boolean deliveryModePriceRangeEnable;
	
	@Column(name = "custommer_vip")
	private String custommerVip = "";
	
	@Column(name = "price_type")
	private String priceType;
	
	public DomainRule() {
		// can update
		promotionCodeEnable = false;
		channelEnable = false;
		languageEnable = false;
		paymentModeEnable = false;
		shippingModeEnable = false;
		salesIdEnable = false;
		cityTypeEnable = false;
		familyEnable = false;
		subFamilyEnable = false;
		productCodeEnable = false;
		oneProductForEachSubFamilyEnable = false;
		lotsEnable = false;
		brandEnable = false;
		offerIdEnable = false;
		bundleDefinitionEnable = false;
		giftEnable = false;
		orderShippingFeeEnable = false;
		orderlineShippingFeeEnable = false;
		orderProposeDiscountEnable = false;
		orderlineSellingPriceEnable = false;
		discountForCheapestRefcoEnable = false;
		moreThanXOfFamilyEnable = false;
		addRefcoFromSalesupportEnable = false;
		addRefcoOfOrderEnable = false;
		addRefcoEnable = false;
		shippingDiscountPercentEnable = false;
		orderDiscountPercentEnable = false;
		productIdEnable = false;
	}

	public void setDomainRule(ConditionItem condItem, AdvantageItem advItem) {
		// can update
		// Get extra field
		if (condItem.getDomainRuleId() != null) {
			this.setDomainRuleId(condItem.getDomainRuleId());
		} else {
			this.setDomainRuleId(null); // allow to be null
		}

		if (condItem.getRuleId() != null) {
			this.setRuleId(condItem.getRuleId());
		} else {
			this.setRuleId("");
		}

		if (condItem.getRuleName() != null) {
			this.setRuleName(condItem.getRuleName());
		} else {
			this.setRuleName("");
		}

		if (condItem.getDescription() != null) {
			this.setDescription(condItem.getDescription());
		} else {
			this.setDescription("");
		}

		if (condItem.getDescriptionId() != null) {
			this.setDescriptionId(condItem.getDescriptionId());
		} else {
			this.setDescriptionId("");
		}

		this.setSalience(condItem.getSalience());

		if (condItem.getEnvironment() != null) {
			this.setEnvironment(condItem.getEnvironment());
		} else {
			Environment env = new Environment();
			env.setEnvironmentId(Constants.UAT_ENVIROMENT);
			env.setEnvironmentName(Constants.UAT_ENVIROMENT_MESSAGE);

			this.setEnvironment(env);
		}

		// Get values from ConditionItem
		if (condItem.getBusLine() != null) {
			this.setBusLine(condItem.getBusLine());
		} else {
			this.setBusLine("");
		}

		if (condItem.getCountry() != null) {
			this.setCountry(condItem.getCountry());
		} else {
			this.setCountry("");
		}

		if (condItem.getProductIdEnable() != null) {
			this.setProductIdEnable(condItem.getProductIdEnable());
		} else {
			this.setProductIdEnable(false);
		}

		if (condItem.getProductIdValue() != null) {
			this.setProductIdValue(condItem.getProductIdValue());
		} else {
			this.setProductIdValue("");
		}

		if (condItem.getBeginDate() != null) {
			this.setBeginDate(condItem.getBeginDate());
		} else {
			this.setBeginDate(new Date());
		}

		if (condItem.getEndDate() != null) {
			this.setEndDate(condItem.getEndDate());
		} else {
			this.setEndDate(null);
		}

		if (condItem.getPromotionCodeEnable() != null) {
			this.setPromotionCodeEnable(condItem.getPromotionCodeEnable());
		} else {
			this.setPromotionCodeEnable(false);
		}

		if (condItem.getPromotionValue() != null) {
			this.setPromotionValue(condItem.getPromotionValue());
		} else {
			this.setPromotionValue("");
		}

		if (condItem.getChannelEnable() != null) {
			this.setChannelEnable(condItem.getChannelEnable());
		} else {
			this.setChannelEnable(false);
		}

		if (condItem.getChannelValue() != null) {
			this.setChannelValue(condItem.getChannelValue());
		} else {
			this.setChannelValue("");
		}

		if (condItem.getLanguageEnable() != null) {
			this.setLanguageEnable(condItem.getLanguageEnable());
		} else {
			this.setLanguageEnable(false);
		}

		if (condItem.getLanguageValue() != null) {
			this.setLanguageValue(condItem.getLanguageValue());
		} else {
			this.setLanguageValue("");
		}

		if (condItem.getPaymentModeEnable() != null) {
			this.setPaymentModeEnable(condItem.getPaymentModeEnable());
		} else {
			this.setPaymentModeEnable(false);
		}

		if (condItem.getPaymentModeValue() != null) {
			this.setPaymentModeValue(condItem.getPaymentModeValue());
		} else {
			this.setPaymentModeValue("");
		}

		if (condItem.getShippingModeEnable() != null) {
			this.setShippingModeEnable(condItem.getShippingModeEnable());
		} else {
			this.setShippingModeEnable(false);
		}

		if (condItem.getShippingModeValue() != null) {
			this.setShippingModeValue(condItem.getShippingModeValue());
		} else {
			this.setShippingModeValue("");
		}

		if (condItem.getSalesIdEnable() != null) {
			this.setSalesIdEnable(condItem.getSalesIdEnable());
		} else {
			this.setSalesIdEnable(false);
		}

		if (condItem.getSalesIdValue() != null) {
			this.setSalesIdValue(condItem.getSalesIdValue());
		} else {
			this.setSalesIdValue("");
		}

		if (condItem.getCityTypeEnable() != null) {
			this.setCityTypeEnable(condItem.getCityTypeEnable());
		} else {
			this.setCityTypeEnable(false);
		}

		if (condItem.getCityTypeValue() != null) {
			this.setCityTypeValue(condItem.getCityTypeValue());
		} else {
			this.setCityTypeValue("");
		}

		if (condItem.getCurrencyEnable() != null) {
			this.setCurrencyEnable(condItem.getCurrencyEnable());
		} else {
			this.setCurrencyEnable(false);
		}

		if (condItem.getCurrencyValue() != null) {
			this.setCurrencyValue(condItem.getCurrencyValue());
		} else {
			this.setCurrencyValue("");
		}

		if (condItem.getOrderAmount() != null) {
			this.setOrderAmount(condItem.getOrderAmount());
		} else {
			this.setOrderAmount("");
		}

		if (condItem.getNetAmount() != null) {
			this.setNetAmount(condItem.getNetAmount());
		} else {
			this.setNetAmount("");
		}

		if (condItem.getLineAmount() != null) {
			this.setLineAmount(condItem.getLineAmount());
		} else {
			this.setLineAmount("");
		}

		if (condItem.getNbOfItemsPerOrder() != null) {
			this.setNbOfItemsPerOrder(condItem.getNbOfItemsPerOrder());
		} else {
			this.setNbOfItemsPerOrder("");
		}

		if (condItem.getMarketingActionCode() != null) {
			this.setMarketingActionCode(condItem.getMarketingActionCode());
		} else {
			this.setMarketingActionCode("");
		}

		if (condItem.getFamilyEnable() != null) {
			this.setFamilyEnable(condItem.getFamilyEnable());
		} else {
			this.setFamilyEnable(false);
		}

		if (condItem.getFamilyValue() != null) {
			this.setFamilyValue(condItem.getFamilyValue());
		} else {
			this.setFamilyValue("");
		}

		if (condItem.getSubFamilyEnable() != null) {
			this.setSubFamilyEnable(condItem.getSubFamilyEnable());
		} else {
			this.setSubFamilyEnable(false);
		}

		if (condItem.getSubFamilyValue() != null) {
			this.setSubFamilyValue(condItem.getSubFamilyValue());
		} else {
			this.setSubFamilyValue("");
		}

		if (condItem.getCategoryEnable() != null) {
			this.setCategoryEnable(condItem.getCategoryEnable());
		} else {
			this.setCategoryEnable(false);
		}

		if (condItem.getCategoryValue() != null) {
			this.setCategoryValue(condItem.getCategoryValue());
		} else {
			this.setCategoryValue("");
		}

		if (condItem.getProductCodeEnable() != null) {
			this.setProductCodeEnable(condItem.getProductCodeEnable());
		} else {
			this.setProductCodeEnable(false);
		}

		if (condItem.getProductCodeValue() != null) {
			this.setProductCodeValue(condItem.getProductCodeValue());
		} else {
			this.setProductCodeValue("");
		}

		if (condItem.getOneProductForEachSubFamilyEnable() != null) {
			this.setOneProductForEachSubFamilyEnable(condItem
					.getOneProductForEachSubFamilyEnable());
		} else {
			this.setOneProductForEachSubFamilyEnable(false);
		}

		if (condItem.getOneProductForEachSubFamilyValue() != null) {
			this.setOneProductForEachSubFamilyValue(condItem
					.getOneProductForEachSubFamilyValue());
		} else {
			this.setOneProductForEachSubFamilyValue("");
		}

		if (condItem.getLotsEnable() != null) {
			this.setLotsEnable(condItem.getLotsEnable());
		} else {
			this.setLotsEnable(false);
		}

		if (condItem.getLotsValue() != null) {
			this.setLotsValue(condItem.getLotsValue());
		} else {
			this.setLotsValue("");
		}

		if (condItem.getBrandEnable() != null) {
			this.setBrandEnable(condItem.getBrandEnable());
		} else {
			this.setBrandEnable(false);
		}

		if (condItem.getBrandValue() != null) {
			this.setBrandValue(condItem.getBrandValue());
		} else {
			this.setBrandValue("");
		}

		if (condItem.getOfferIdEnable() != null) {
			this.setOfferIdEnable(condItem.getOfferIdEnable());
		} else {
			this.setOfferIdEnable(false);
		}

		if (condItem.getOfferIdValue() != null) {
			this.setOfferIdValue(condItem.getOfferIdValue());
		} else {
			this.setOfferIdValue("");
		}

		if (condItem.getBundleDefinitionEnable() != null) {
			this.setBundleDefinitionEnable(condItem.getBundleDefinitionEnable());
		} else {
			this.setBundleDefinitionEnable(false);
		}

		if (condItem.getBundleDefinitionValue() != null) {
			this.setBundleDefinitionValue(condItem.getBundleDefinitionValue());
		} else {
			this.setBundleDefinitionValue("");
		}

		if (condItem.getMoreThanXOfFamilyEnable() != null) {
			this.setMoreThanXOfFamilyEnable(condItem
					.getMoreThanXOfFamilyEnable());
		} else {
			this.setMoreThanXOfFamilyEnable(false);
		}

		if (condItem.getMoreThanXOfFamilyValue() != null) {
			this.setMoreThanXOfFamilyValue(condItem.getMoreThanXOfFamilyValue());
		} else {
			this.setMoreThanXOfFamilyValue("");
		}

		if (condItem.getDeliveryModePriceRangeEnable() != null) {
			this.setDeliveryModePriceRangeEnable(condItem.getDeliveryModePriceRangeEnable());
		} else {
			this.setDeliveryModePriceRangeEnable(Boolean.FALSE);
		}
		
		if (condItem.getDeliveryModePriceRangeValue() != null) {
			this.setDeliveryModePriceRangeValue(condItem.getDeliveryModePriceRangeValue());
		} else {
			this.setDeliveryModePriceRangeValue("");
		}

		if (condItem.getCustommerVip() != null) {
			this.setCustommerVip(condItem.getCustommerVip());
		} else {
			this.setCustommerVip(CustomerVip.NONE.value());
		}

		if (condItem.getPriceType() != null) {
			this.setPriceType(condItem.getPriceType());
		} else {
			this.setPriceType(null);
		}

		this.setPromotionActive(condItem.getPromotionActive());

		if (advItem.getGiftEnable() != null) {
			this.setGiftEnable(advItem.getGiftEnable());
		} else {
			this.setGiftEnable(false);
		}

		if (advItem.getProductCode() != null) {
			this.setProductCode(advItem.getProductCode());
		} else {
			this.setProductCode("");
		}

		if (advItem.getProductId() != null) {
			this.setProductId(advItem.getProductId());
		} else {
			this.setProductId("");
		}

		if (advItem.getCommercialRef() != null) {
			this.setCommercialRef(advItem.getCommercialRef());
		} else {
			this.setCommercialRef("");
		}

		if (advItem.getItemId() != null) {
			this.setItemId(advItem.getItemId());
		} else {
			this.setItemId("");
		}

		if (advItem.getOrderShippingFeeEnable() != null) {
			this.setOrderShippingFeeEnable(advItem.getOrderShippingFeeEnable());
		} else {
			this.setOrderShippingFeeEnable(false);
		}

		if (advItem.getOrderShippingFeeValue() != null) {
			this.setOrderShippingFeeValue(advItem.getOrderShippingFeeValue());
		} else {
			this.setOrderShippingFeeValue("");
		}

		if (advItem.getOrderlineShippingFeeEnable() != null) {
			this.setOrderlineShippingFeeEnable(advItem
					.getOrderlineShippingFeeEnable());
		} else {
			this.setOrderlineShippingFeeEnable(false);
		}

		if (advItem.getOrderlineShippingFeeValue() != null) {
			this.setOrderlineShippingFeeValue(advItem
					.getOrderlineShippingFeeValue());
		} else {
			this.setOrderlineShippingFeeValue("");
		}

		if (advItem.getOrderlineDiscountPercentageEnable() != null) {
			this.setOrderlineDiscountPercentageEnable(advItem
					.getOrderlineDiscountPercentageEnable());
		} else {
			this.setOrderlineDiscountPercentageEnable(false);
		}

		if (advItem.getOrderlineDiscountEnable() != null) {
			this.setOrderlineDiscountEnable(advItem
					.getOrderlineDiscountEnable());
		} else {
			this.setOrderlineDiscountEnable(false);
		}

		if (advItem.getOrderlineDiscountPercentage() != null) {
			this.setOrderlineDiscountPercentageValue(advItem
					.getOrderlineDiscountPercentage());
		} else {
			this.setOrderlineDiscountPercentageValue("");
		}

		if (advItem.getOrderlineDiscount() != null) {
			this.setOrderlineDiscountValue(advItem
					.getOrderlineDiscount());
		} else {
			this.setOrderlineDiscountValue("");
		}

		if (advItem.getOrderlineShippingFeeDiscountPercentageEnable() != null) {
			this.setOrderlineShippingFeeDiscountPercentageEnable(advItem
					.getOrderlineShippingFeeDiscountPercentageEnable());
		} else {
			this.setOrderlineShippingFeeDiscountPercentageEnable(false);
		}

		if (advItem.getOrderlineShippingFeeDiscountPercentage() != null) {
			this.setOrderlineShippingFeeDiscountPercentageValue(advItem
					.getOrderlineShippingFeeDiscountPercentage());
		} else {
			this.setOrderlineShippingFeeDiscountPercentageValue("");
		}

		if (advItem.getOrderProposeDiscountEnable() != null) {
			this.setOrderProposeDiscountEnable(advItem
					.getOrderProposeDiscountEnable());
		} else {
			this.setOrderProposeDiscountEnable(false);
		}

		if (advItem.getOrderProposeDiscountValue() != null) {
			this.setOrderProposeDiscountValue(advItem
					.getOrderProposeDiscountValue());
		} else {
			this.setOrderProposeDiscountValue("");
		}

		if (advItem.getOrderlineSellingPriceEnable() != null) {
			this.setOrderlineSellingPriceEnable(advItem
					.getOrderlineSellingPriceEnable());
		} else {
			this.setOrderlineSellingPriceEnable(false);
		}

		if (advItem.getOrderlineSellingPriceValue() != null) {
			this.setOrderlineSellingPriceValue(advItem
					.getOrderlineSellingPriceValue());
		} else {
			this.setOrderlineSellingPriceValue("");
		}

		if (advItem.getDiscountForCheapestRefcoEnable() != null) {
			this.setDiscountForCheapestRefcoEnable(advItem
					.getDiscountForCheapestRefcoEnable());
		} else {
			this.setDiscountForCheapestRefcoEnable(false);
		}

		if (advItem.getFamily() != null) {
			this.setFamily(advItem.getFamily());
		} else {
			this.setFamily("0");
		}

		if (advItem.getAddRefcoFromSalesupportEnable() != null) {
			this.setAddRefcoFromSalesupportEnable(advItem
					.getAddRefcoFromSalesupportEnable());
		} else {
			this.setAddRefcoFromSalesupportEnable(false);
		}

		if (advItem.getFromSalesupportOffer() != null) {
			this.setFromSalesupportOffer(advItem.getFromSalesupportOffer());
		} else {
			this.setFromSalesupportOffer("");
		}

		if (advItem.getCategory() != null) {
			this.setCategory(advItem.getCategory());
		} else {
			this.setCategory("");
		}

		if (advItem.getAddRefcoOfOrderEnable() != null) {
			this.setAddRefcoOfOrderEnable(advItem.getAddRefcoOfOrderEnable());
		} else {
			this.setAddRefcoOfOrderEnable(false);
		}

		if (advItem.getOfOrderOffer() != null) {
			this.setOfOrderOffer(advItem.getOfOrderOffer());
		} else {
			this.setOfOrderOffer("");
		}

		if (advItem.getAddRefcoEnable() != null) {
			this.setAddRefcoEnable(advItem.getAddRefcoEnable());
		} else {
			this.setAddRefcoEnable(false);
		}

		if (advItem.getRefco() != null) {
			this.setRefco(advItem.getRefco());
		} else {
			this.setRefco("");
		}

		if (advItem.getShippingDiscountPercentEnable() != null) {
			this.setShippingDiscountPercentEnable(advItem
					.getShippingDiscountPercentEnable());
		} else {
			this.setShippingDiscountPercentEnable(false);
		}

		if (advItem.getShippingDiscountPercentValue() != null) {
			this.setShippingDiscountPercentValue(advItem
					.getShippingDiscountPercentValue());
		} else {
			this.setShippingDiscountPercentValue("");
		}

		if (advItem.getOrderDiscountPercentEnable() != null) {
			this.setOrderDiscountPercentEnable(advItem
					.getOrderDiscountPercentEnable());
		} else {
			this.setOrderDiscountPercentEnable(false);
		}

		if (advItem.getOrderDiscountPercentValue() != null) {
			this.setOrderDiscountPercentValue(advItem
					.getOrderDiscountPercentValue());
		} else {
			this.setOrderDiscountPercentValue("");
		}
	}

	public String getShippingDiscountPercentValue() {
		return shippingDiscountPercentValue;
	}

	public void setShippingDiscountPercentValue(
			String shippingDiscountPercentValue) {
		this.shippingDiscountPercentValue = shippingDiscountPercentValue;
	}

	public Boolean getShippingDiscountPercentEnable() {
		return shippingDiscountPercentEnable;
	}

	public void setShippingDiscountPercentEnable(
			Boolean shippingDiscountPercentEnable) {
		this.shippingDiscountPercentEnable = shippingDiscountPercentEnable;
	}

	public String getOrderDiscountPercentValue() {
		return orderDiscountPercentValue;
	}

	public void setOrderDiscountPercentValue(String orderDiscountPercentValue) {
		this.orderDiscountPercentValue = orderDiscountPercentValue;
	}

	public Boolean getOrderDiscountPercentEnable() {
		return orderDiscountPercentEnable;
	}

	public void setOrderDiscountPercentEnable(Boolean orderDiscountPercentEnable) {
		this.orderDiscountPercentEnable = orderDiscountPercentEnable;
	}

	public Long getDomainRuleId() {
		return domainRuleId;
	}

	public void setDomainRuleId(Long domainRuleId) {
		this.domainRuleId = domainRuleId;
	}

	public String getRuleId() {
		return ruleId;
	}

	public void setRuleId(String ruleId) {
		this.ruleId = ruleId;
	}

	public String getRuleName() {
		return ruleName;
	}

	public void setRuleName(String ruleName) {
		this.ruleName = ruleName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getDescriptionId() {
		return descriptionId;
	}

	public String getProductIdValue() {
		return productIdValue;
	}

	public void setProductIdValue(String productIdValue) {
		this.productIdValue = productIdValue;
	}

	public Boolean getProductIdEnable() {
		return productIdEnable;
	}

	public void setProductIdEnable(Boolean productIdEnable) {
		this.productIdEnable = productIdEnable;
	}

	public void setDescriptionId(String descriptionId) {
		this.descriptionId = descriptionId;
	}

	public String getProductCode() {
		return productCode;
	}

	public void setProductCode(String productCode) {
		this.productCode = productCode;
	}

	public String getProductId() {
		return productId;
	}

	public void setProductId(String productId) {
		this.productId = productId;
	}

	public int getSalience() {
		return salience;
	}

	public void setSalience(int salience) {
		this.salience = salience;
	}

	public String getBusLine() {
		return busLine;
	}

	public void setBusLine(String busLine) {
		this.busLine = busLine;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public Date getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public Boolean getPromotionCodeEnable() {
		return promotionCodeEnable;
	}

	public void setPromotionCodeEnable(Boolean promotionCodeEnable) {
		this.promotionCodeEnable = promotionCodeEnable;
	}

	public String getPromotionValue() {
		return promotionValue;
	}

	public void setPromotionValue(String promotionValue) {
		this.promotionValue = promotionValue;
	}

	public Boolean getCurrencyEnable() {
		return currencyEnable;
	}

	public void setCurrencyEnable(Boolean currencyEnable) {
		this.currencyEnable = currencyEnable;
	}

	public String getCurrencyValue() {
		return currencyValue;
	}

	public void setCurrencyValue(String currencyValue) {
		this.currencyValue = currencyValue;
	}

	public Boolean getChannelEnable() {
		return channelEnable;
	}

	public void setChannelEnable(Boolean channelEnable) {
		this.channelEnable = channelEnable;
	}

	public String getChannelValue() {
		return channelValue;
	}

	public void setChannelValue(String channelValue) {
		this.channelValue = channelValue;
	}

	public Boolean getLanguageEnable() {
		return languageEnable;
	}

	public void setLanguageEnable(Boolean languageEnable) {
		this.languageEnable = languageEnable;
	}

	public String getLanguageValue() {
		return languageValue;
	}

	public void setLanguageValue(String languageValue) {
		this.languageValue = languageValue;
	}

	public Boolean getPaymentModeEnable() {
		return paymentModeEnable;
	}

	public void setPaymentModeEnable(Boolean paymentModeEnable) {
		this.paymentModeEnable = paymentModeEnable;
	}

	public String getPaymentModeValue() {
		return paymentModeValue;
	}

	public void setPaymentModeValue(String paymentModeValue) {
		this.paymentModeValue = paymentModeValue;
	}

	public Boolean getShippingModeEnable() {
		return shippingModeEnable;
	}

	public void setShippingModeEnable(Boolean shippingModeEnable) {
		this.shippingModeEnable = shippingModeEnable;
	}

	public String getShippingModeValue() {
		return shippingModeValue;
	}

	public void setShippingModeValue(String shippingModeValue) {
		this.shippingModeValue = shippingModeValue;
	}

	public Boolean getSalesIdEnable() {
		return salesIdEnable;
	}

	public void setSalesIdEnable(Boolean salesIdEnable) {
		this.salesIdEnable = salesIdEnable;
	}

	public String getSalesIdValue() {
		return salesIdValue;
	}

	public void setSalesIdValue(String salesIdValue) {
		this.salesIdValue = salesIdValue;
	}

	public Boolean getCityTypeEnable() {
		return cityTypeEnable;
	}

	public void setCityTypeEnable(Boolean cityTypeEnable) {
		this.cityTypeEnable = cityTypeEnable;
	}

	public String getCityTypeValue() {
		return cityTypeValue;
	}

	public void setCityTypeValue(String cityTypeValue) {
		this.cityTypeValue = cityTypeValue;
	}

	public String getOrderAmount() {
		return orderAmount;
	}

	public void setOrderAmount(String orderAmount) {
		this.orderAmount = orderAmount;
	}

	public String getNetAmount() {
		return netAmount;
	}

	public void setNetAmount(String netAmount) {
		this.netAmount = netAmount;
	}

	public String getLineAmount() {
		return lineAmount;
	}

	public void setLineAmount(String lineAmount) {
		this.lineAmount = lineAmount;
	}

	public String getNbOfItemsPerOrder() {
		return nbOfItemsPerOrder;
	}

	public void setNbOfItemsPerOrder(String nbOfItemsPerOrder) {
		this.nbOfItemsPerOrder = nbOfItemsPerOrder;
	}

	public String getMarketingActionCode() {
		return marketingActionCode;
	}

	public void setMarketingActionCode(String marketingActionCode) {
		this.marketingActionCode = marketingActionCode;
	}

	public Boolean getFamilyEnable() {
		return familyEnable;
	}

	public void setFamilyEnable(Boolean familyEnable) {
		this.familyEnable = familyEnable;
	}

	public String getFamilyValue() {
		return familyValue;
	}

	public void setFamilyValue(String familyValue) {
		this.familyValue = familyValue;
	}

	public Boolean getSubFamilyEnable() {
		return subFamilyEnable;
	}

	public void setSubFamilyEnable(Boolean subFamilyEnable) {
		this.subFamilyEnable = subFamilyEnable;
	}

	public String getSubFamilyValue() {
		return subFamilyValue;
	}

	public void setSubFamilyValue(String subFamilyValue) {
		this.subFamilyValue = subFamilyValue;
	}

	public Boolean getProductCodeEnable() {
		return productCodeEnable;
	}

	public void setProductCodeEnable(Boolean productCodeEnable) {
		this.productCodeEnable = productCodeEnable;
	}

	public String getProductCodeValue() {
		return productCodeValue;
	}

	public void setProductCodeValue(String productCodeValue) {
		this.productCodeValue = productCodeValue;
	}

	public Boolean getOneProductForEachSubFamilyEnable() {
		return oneProductForEachSubFamilyEnable;
	}

	public void setOneProductForEachSubFamilyEnable(
			Boolean oneProductForEachSubFamilyEnable) {
		this.oneProductForEachSubFamilyEnable = oneProductForEachSubFamilyEnable;
	}

	public String getOneProductForEachSubFamilyValue() {
		return oneProductForEachSubFamilyValue;
	}

	public void setOneProductForEachSubFamilyValue(
			String oneProductForEachSubFamilyValue) {
		this.oneProductForEachSubFamilyValue = oneProductForEachSubFamilyValue;
	}

	public Boolean getLotsEnable() {
		return lotsEnable;
	}

	public void setLotsEnable(Boolean lotsEnable) {
		this.lotsEnable = lotsEnable;
	}

	public String getLotsValue() {
		return lotsValue;
	}

	public void setLotsValue(String lotsValue) {
		this.lotsValue = lotsValue;
	}

	public Boolean getBrandEnable() {
		return brandEnable;
	}

	public void setBrandEnable(Boolean brandEnable) {
		this.brandEnable = brandEnable;
	}

	public String getBrandValue() {
		return brandValue;
	}

	public void setBrandValue(String brandValue) {
		this.brandValue = brandValue;
	}

	public Boolean getOfferIdEnable() {
		return offerIdEnable;
	}

	public void setOfferIdEnable(Boolean offerIdEnable) {
		this.offerIdEnable = offerIdEnable;
	}

	public String getOfferIdValue() {
		return offerIdValue;
	}

	public void setOfferIdValue(String offerIdValue) {
		this.offerIdValue = offerIdValue;
	}

	public Boolean getBundleDefinitionEnable() {
		return bundleDefinitionEnable;
	}

	public void setBundleDefinitionEnable(Boolean bundleDefinitionEnable) {
		this.bundleDefinitionEnable = bundleDefinitionEnable;
	}

	public String getBundleDefinitionValue() {
		return bundleDefinitionValue;
	}

	public void setBundleDefinitionValue(String bundleDefinitionValue) {
		this.bundleDefinitionValue = bundleDefinitionValue;
	}

	public Boolean getGiftEnable() {
		return giftEnable;
	}

	public void setGiftEnable(Boolean giftEnable) {
		this.giftEnable = giftEnable;
	}

	public String getCommercialRef() {
		return commercialRef;
	}

	public void setCommercialRef(String commercialRef) {
		this.commercialRef = commercialRef;
	}

	public String getItemId() {
		return itemId;
	}

	public void setItemId(String itemId) {
		this.itemId = itemId;
	}

	public Boolean getOrderShippingFeeEnable() {
		return orderShippingFeeEnable;
	}

	public void setOrderShippingFeeEnable(Boolean orderShippingFeeEnable) {
		this.orderShippingFeeEnable = orderShippingFeeEnable;
	}

	public String getOrderShippingFeeValue() {
		return orderShippingFeeValue;
	}

	public void setOrderShippingFeeValue(String orderShippingFeeValue) {
		this.orderShippingFeeValue = orderShippingFeeValue;
	}

	public Boolean getOrderlineShippingFeeEnable() {
		return orderlineShippingFeeEnable;
	}

	public void setOrderlineShippingFeeEnable(Boolean orderlineShippingFeeEnable) {
		this.orderlineShippingFeeEnable = orderlineShippingFeeEnable;
	}

	public Boolean getOrderlineDiscountPercentageEnable() {
		return orderlineDiscountPercentageEnable;
	}

	public void setOrderlineDiscountPercentageEnable(
			Boolean orderlineDiscountPercentageEnable) {
		this.orderlineDiscountPercentageEnable = orderlineDiscountPercentageEnable;
	}

	public String getOrderlineDiscountPercentageValue() {
		return orderlineDiscountPercentageValue;
	}

	public void setOrderlineDiscountPercentageValue(
			String orderlineDiscountPercentageValue) {
		this.orderlineDiscountPercentageValue = orderlineDiscountPercentageValue;
	}

	public Boolean getOrderlineDiscountEnable() {
		return orderlineDiscountEnable;
	}

	public void setOrderlineDiscountEnable(Boolean orderlineDiscountEnable) {
		this.orderlineDiscountEnable = orderlineDiscountEnable;
	}

	public String getOrderlineDiscountValue() {
		return orderlineDiscountValue;
	}

	public void setOrderlineDiscountValue(String orderlineDiscountValue) {
		this.orderlineDiscountValue = orderlineDiscountValue;
	}

	public Boolean getOrderlineShippingFeeDiscountPercentageEnable() {
		return orderlineShippingFeeDiscountPercentageEnable;
	}

	public void setOrderlineShippingFeeDiscountPercentageEnable(
			Boolean orderlineShippingFeeDiscountPercentageEnable) {
		this.orderlineShippingFeeDiscountPercentageEnable = orderlineShippingFeeDiscountPercentageEnable;
	}

	public String getOrderlineShippingFeeDiscountPercentageValue() {
		return orderlineShippingFeeDiscountPercentageValue;
	}

	public void setOrderlineShippingFeeDiscountPercentageValue(
			String orderlineShippingFeeDiscountPercentageValue) {
		this.orderlineShippingFeeDiscountPercentageValue = orderlineShippingFeeDiscountPercentageValue;
	}

	public String getOrderlineShippingFeeValue() {
		if (StringUtils.isEmpty(orderlineShippingFeeValue)) {
			orderlineShippingFeeValue = "0.000";
		}
		return orderlineShippingFeeValue;
	}

	public void setOrderlineShippingFeeValue(String orderlineShippingFeeValue) {
		this.orderlineShippingFeeValue = orderlineShippingFeeValue;
	}

	public Boolean getOrderProposeDiscountEnable() {
		return orderProposeDiscountEnable;
	}

	public void setOrderProposeDiscountEnable(Boolean orderProposeDiscountEnable) {
		this.orderProposeDiscountEnable = orderProposeDiscountEnable;
	}

	public String getOrderProposeDiscountValue() {
		return orderProposeDiscountValue;
	}

	public void setOrderProposeDiscountValue(String orderProposeDiscountValue) {
		this.orderProposeDiscountValue = orderProposeDiscountValue;
	}

	public Boolean getOrderlineSellingPriceEnable() {
		return orderlineSellingPriceEnable;
	}

	public Environment getEnvironment() {
		if (environment == null)
			environment = new Environment();
		return environment;
	}

	public void setEnvironment(Environment environment) {
		if (environment != null)
			this.environment = environment;
	}

	public void setOrderlineSellingPriceEnable(
			Boolean orderlineSellingPriceEnable) {
		this.orderlineSellingPriceEnable = orderlineSellingPriceEnable;
	}

	public String getOrderlineSellingPriceValue() {
		return orderlineSellingPriceValue;
	}

	public void setOrderlineSellingPriceValue(String orderlineSellingPriceValue) {
		this.orderlineSellingPriceValue = orderlineSellingPriceValue;
	}

	public Boolean getDiscountForCheapestRefcoEnable() {
		return discountForCheapestRefcoEnable;
	}

	public void setDiscountForCheapestRefcoEnable(
			Boolean discountForCheapestRefcoEnable) {
		this.discountForCheapestRefcoEnable = discountForCheapestRefcoEnable;
	}

	public String getFamily() {
		return family;
	}

	public void setFamily(String family) {
		this.family = family;
	}

	public Boolean getAddRefcoFromSalesupportEnable() {
		return addRefcoFromSalesupportEnable;
	}

	public void setAddRefcoFromSalesupportEnable(
			Boolean addRefcoFromSalesupportEnable) {
		this.addRefcoFromSalesupportEnable = addRefcoFromSalesupportEnable;
	}

	public String getFromSalesupportOffer() {
		return fromSalesupportOffer;
	}

	public void setFromSalesupportOffer(String fromSalesupportOffer) {
		this.fromSalesupportOffer = fromSalesupportOffer;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public Boolean getAddRefcoOfOrderEnable() {
		return addRefcoOfOrderEnable;
	}

	public void setAddRefcoOfOrderEnable(Boolean addRefcoOfOrderEnable) {
		this.addRefcoOfOrderEnable = addRefcoOfOrderEnable;
	}

	public String getOfOrderOffer() {
		return ofOrderOffer;
	}

	public void setOfOrderOffer(String ofOrderOffer) {
		this.ofOrderOffer = ofOrderOffer;
	}

	public Boolean getAddRefcoEnable() {
		return addRefcoEnable;
	}

	public void setAddRefcoEnable(Boolean addRefcoEnable) {
		this.addRefcoEnable = addRefcoEnable;
	}

	public String getRefco() {
		return refco;
	}

	public void setRefco(String refco) {
		this.refco = refco;
	}

	public Boolean getCategoryEnable() {
		return categoryEnable;
	}

	public void setCategoryEnable(Boolean categoryEnable) {
		this.categoryEnable = categoryEnable;
	}

	public String getCategoryValue() {
		return categoryValue;
	}

	public void setCategoryValue(String categoryValue) {
		this.categoryValue = categoryValue;
	}

	public Boolean getMoreThanXOfFamilyEnable() {
		return moreThanXOfFamilyEnable;
	}

	public void setMoreThanXOfFamilyEnable(Boolean moreThanXOfFamilyEnable) {
		this.moreThanXOfFamilyEnable = moreThanXOfFamilyEnable;
	}

	public String getMoreThanXOfFamilyValue() {
		return moreThanXOfFamilyValue;
	}

	public void setMoreThanXOfFamilyValue(String moreThanXOfFamilyValue) {
		this.moreThanXOfFamilyValue = moreThanXOfFamilyValue;
	}

	public Boolean getPromotionActive() {
		return promotionActive;
	}

	public void setPromotionActive(Boolean promotionActive) {
		this.promotionActive = promotionActive;
	}

	public String getDeliveryModePriceRangeValue() {
		return deliveryModePriceRangeValue;
	}

	public void setDeliveryModePriceRangeValue(String deliveryModePriceRangeValue) {
		this.deliveryModePriceRangeValue = deliveryModePriceRangeValue;
	}

	public Boolean getDeliveryModePriceRangeEnable() {
		return deliveryModePriceRangeEnable;
	}

	public void setDeliveryModePriceRangeEnable(Boolean deliveryModePriceRangeEnable) {
		this.deliveryModePriceRangeEnable = deliveryModePriceRangeEnable;
	}

	public String getCustommerVip() {
		return custommerVip;
	}

	public void setCustommerVip(String custommerVip) {
		this.custommerVip = custommerVip;
	}
	
	@Transient
	public Boolean getVipStatus() {
		return !StringUtils.isEmpty(custommerVip) && custommerVip.equals(CustomerVip.VIP.value());
	}

	public DomainRule copyWithoutKey() {
		DomainRule domainRule = copy();
		domainRule.setDomainRuleId(null);

		return domainRule;
	}

	public DomainRule copy() {
		DomainRule p = new DomainRule();
		ConditionItem cond = getConditionItem();
		AdvantageItem adv = getAdvantageItem();
		p.setDomainRule(cond, adv);

		return p;
	}

	@Transient
	public ConditionItem getConditionItem() {
		// can update
		ConditionItem item = new ConditionItem();

		// extra fields
		item.setDomainRuleId(this.getDomainRuleId());
		item.setRuleId(this.getRuleId());
		item.setRuleName(this.getRuleName());
		item.setDescription(this.getDescription());
		item.setDescriptionId(this.getDescriptionId());
		item.setSalience(this.getSalience());
		item.setEnvironment(this.getEnvironment());

		item.setProductIdEnable(this.getProductIdEnable());
		item.setProductIdValue(this.getProductIdValue());
		item.setBusLine(this.getBusLine());
		item.setCountry(this.getCountry());
		item.setBeginDate(this.getBeginDate());
		item.setEndDate(this.getEndDate());
		item.setPromotionCodeEnable(this.getPromotionCodeEnable());
		item.setPromotionValue(this.getPromotionValue());
		item.setChannelEnable(this.getChannelEnable());
		item.setChannelValue(this.getChannelValue());
		item.setLanguageEnable(this.getLanguageEnable());
		item.setLanguageValue(this.getLanguageValue());
		item.setPaymentModeEnable(this.getPaymentModeEnable());
		item.setPaymentModeValue(this.getPaymentModeValue());
		item.setShippingModeEnable(this.getShippingModeEnable());
		item.setShippingModeValue(this.getShippingModeValue());
		item.setSalesIdEnable(this.getSalesIdEnable());
		item.setSalesIdValue(this.getSalesIdValue());
		item.setCityTypeEnable(this.getCityTypeEnable());
		item.setCityTypeValue(this.getCityTypeValue());
		item.setOrderAmount(this.getOrderAmount());
		item.setNetAmount(this.getNetAmount());
		item.setLineAmount(this.getLineAmount());
		item.setNbOfItemsPerOrder(this.getNbOfItemsPerOrder());
		item.setMarketingActionCode(this.getMarketingActionCode());
		item.setFamilyEnable(this.getFamilyEnable());
		item.setFamilyValue(this.getFamilyValue());
		item.setSubFamilyEnable(this.getSubFamilyEnable());
		item.setSubFamilyValue(this.getSubFamilyValue());
		item.setCategoryEnable(this.getCategoryEnable());
		item.setCategoryValue(this.getCategoryValue());
		item.setProductCodeEnable(this.getProductCodeEnable());
		item.setProductCodeValue(this.getProductCodeValue());
		item.setOneProductForEachSubFamilyEnable(this
				.getOneProductForEachSubFamilyEnable());
		item.setOneProductForEachSubFamilyValue(this
				.getOneProductForEachSubFamilyValue());
		item.setLotsEnable(this.getLotsEnable());
		item.setLotsValue(this.getLotsValue());
		item.setBrandEnable(this.getBrandEnable());
		item.setBrandValue(this.getBrandValue());
		item.setOfferIdEnable(this.getOfferIdEnable());
		item.setOfferIdValue(this.getOfferIdValue());
		item.setBundleDefinitionEnable(this.getBundleDefinitionEnable());
		item.setBundleDefinitionValue(this.getBundleDefinitionValue());
		item.setCurrencyEnable(this.getCurrencyEnable());
		item.setCurrencyValue(this.getCurrencyValue());
		item.setMoreThanXOfFamilyEnable(this.getMoreThanXOfFamilyEnable());
		item.setMoreThanXOfFamilyValue(this.getMoreThanXOfFamilyValue());
		item.setPromotionActive(this.getPromotionActive());
		item.setDeliveryModePriceRangeEnable(this.getDeliveryModePriceRangeEnable());
		item.setDeliveryModePriceRangeValue(this.getDeliveryModePriceRangeValue());
		item.setCustommerVip(this.getCustommerVip());
		item.setPriceType(PriceType.parse(this.getPriceType()));

		return item;
	}

	@Transient
	public AdvantageItem getAdvantageItem() {
		// can update
		AdvantageItem item = new AdvantageItem();

		item.setGiftEnable(this.getGiftEnable());
		item.setProductCode(this.getProductCode());
		item.setProductId(this.getProductId());
		item.setCommercialRef(this.getCommercialRef());
		item.setItemId(this.getItemId());
		item.setOrderShippingFeeEnable(this.getOrderShippingFeeEnable());
		item.setOrderShippingFeeValue(this.getOrderShippingFeeValue());
		item.setOrderProposeDiscountEnable(this.getOrderProposeDiscountEnable());
		item.setOrderProposeDiscountValue(this.getOrderProposeDiscountValue());

		item.setOrderlineSellingPriceEnable(this.getOrderlineSellingPriceEnable());
		item.setOrderlineSellingPriceValue(this.getOrderlineSellingPriceValue());
		item.setOrderlineDiscountEnable(this.getOrderlineDiscountEnable());
		item.setOrderlineDiscount(this.getOrderlineDiscountValue());
		item.setOrderlineDiscountPercentageEnable(this.getOrderlineDiscountPercentageEnable());
		item.setOrderlineDiscountPercentage(this.getOrderlineDiscountPercentageValue());
		item.setOrderlineShippingFeeEnable(this.getOrderlineShippingFeeEnable());
		item.setOrderlineShippingFeeValue(this.getOrderlineShippingFeeValue());
		item.setOrderlineShippingFeeDiscountPercentageEnable(this.getOrderlineShippingFeeDiscountPercentageEnable());
		item.setOrderlineShippingFeeDiscountPercentage(this.getOrderlineShippingFeeDiscountPercentageValue());
		
		item.setDiscountForCheapestRefcoEnable(this.getDiscountForCheapestRefcoEnable());
		item.setFamily(this.getFamily());
		item.setAddRefcoFromSalesupportEnable(this.getAddRefcoFromSalesupportEnable());
		item.setFromSalesupportOffer(this.getFromSalesupportOffer());
		item.setCategory(this.getCategory());
		item.setAddRefcoOfOrderEnable(this.getAddRefcoOfOrderEnable());
		item.setOfOrderOffer(this.getOfOrderOffer());
		item.setAddRefcoEnable(this.getAddRefcoEnable());
		item.setRefco(this.getRefco());
		item.setShippingDiscountPercentEnable(this.getShippingDiscountPercentEnable());
		item.setShippingDiscountPercentValue(this.getShippingDiscountPercentValue());
		item.setOrderDiscountPercentEnable(this.getOrderDiscountPercentEnable());
		item.setOrderDiscountPercentValue(this.getOrderDiscountPercentValue());
		return item;
	}

	public String getPriceType() {
		return priceType;
	}

	public void setPriceType(PriceType priceType) {
		if (null != priceType) {
			this.priceType = priceType.toString();
		}
	}
	
	@Transient
	public String getFixPriceType() {
		return DomainRule.FIX_PRICE;
	}
	
}
